package com.itheima.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

import javax.sql.DataSource;

@Configuration
@ComponentScan("com.itheima")
@Import(MyBatisConfig.class)
@PropertySource("classpath:jdbc.properties")
public class SpringConfig {
    @Value("jdbc:mysql://localhost:3306/spring_db?useSSL=false")
    private String url;
    @Value("com.mysql.cj.jdbc.Driver")
    private String driver;
    @Value("root")
    private String username;
    @Value("123456")
    private String password;

    @Bean
    public DataSource getDs(){
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName(driver);
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);
        return ds;
    }
}
